<template>
  <div>
    <h1>App根组件</h1>
    <button @click="comName='MyHome'">主页</button>
    <button @click="comName='Movie'">电影</button>
    <hr>
    <keep-alive>
         <component :is="comName"></component>
    </keep-alive>
  </div>
</template>

<script>
import MyHome from './MyHome.vue'
import Movie from './Movie.vue'
export default {
    name:'MyApp',
    data(){
        return{
            // 展示组件的名称
            comName:'MyHome'
        }
    },
    components:{
        MyHome,
        Movie
    }

}
</script>

<style>

</style>